<?php use_helper('Number') ?>
<div class="center_title">
    <?php echo __('receipt list', array()) ?>
</div>
<?php /* @var $receipt Receipt */?>
<div class="center_text">
    <div class="text_item">

        <div class="filter">

            <?php use_helper('Object') ?>

            <?php echo form_tag('cart/list', array('method' => 'get')) ?>

            <div class="receipt_status">
                <?php echo __('Receipt status') ?>:
            </div>
            <div class="filter_list">
                <?php echo select_tag(
                                'filters[status]'
                                , options_for_select(
                                    MyConstants::getStatusList()
                                    , isset($filters['status']) ? $filters['status'] : null
                                    , array(
                                        'include_custom' => __('Choose')
                                    )
                                )
                                , array(
                                    'class' => 'login_input'
                                )
                            )?>
                
            </div>

            <div class="filter_submit">
                <?php echo submit_tag(__('filter'), 'name=filter class=filter_button') ?>
            </div>
            <div class="reset_submit">
                <?php echo button_to(__('reset'), 'cart/list?filter=filter', 'class=filter_button') ?>
            </div>

            </form>

        </div>

    <?php if (!$pager->getNbResults()): ?>
        <?php echo __('No results') ?>.
    <?php else: ?>

            <table width="100%" class="cart" cellpadding="2" cellspacing="1">
                <tr>
                    <th>ID</th>
                    <th><?php echo __('status') ?></th>
                    <th><?php echo __('created at') ?></th>
                    <th><?php echo __('completed at') ?></th>
                    <th><?php echo __('items qnt') ?></th>
                    <th><?php echo __('shipping price') ?></th>
                    <th><?php echo __('total price') ?></th>
                    <th><?php echo __('User info') ?></th>
                </tr>
            <?php $i = 1; foreach ($pager->getResults() as $receipt): $odd = fmod(++$i, 2) ?>
                <tr class="sf_admin_row_<?php echo $odd ?>">
                    <td align="right"><?php echo $receipt->getId();?>
                        <?php echo link_to(__('View')
                                          , 'cart/preview?id='.$receipt->getId()
                                  ) ?>
                    </td>
                    <td align="center">
                    <?php echo image_tag(
                                'status_' . $receipt->getStatusId() . '.png'
                                , array(
                                    'border' => '0'
                                    , 'alt' => __(MyConstants::getStatusName($receipt->getStatusId()))
                                    , 'title' => __(MyConstants::getStatusName($receipt->getStatusId()))
                                )
                            ) ?>
<!--                    <?php echo link_to(
                                    image_tag(
                                        'pdf.png'
                                        , array(
                                            'border' => '0'
                                            , 'alt' => __('create PDF')
                                            , 'title' => __('create PDF')
                                            , 'style' => 'margin-bottom: -3px;'
                                        )
                                    )
                                    , 'cart/receiptpdf?id=' . $receipt->getId()
                                ); ?>-->
                    </td>
                    <td align="center"><?php echo $receipt->getCreatedAt() ?></td>
                    <td align="center"><?php echo $receipt->getCompletedAt() ?></td>
                    <td align="center"><?php echo $receipt->getItemsQnt() ?></td>
                    <td align="center"><?php echo format_currency($receipt->getShippingPriceMinor($sf_user->getAttribute('currency', 'EUR')), $sf_user->getAttribute('currency', 'EUR')) ?></td>
                    <td align="right"><?php echo format_currency($receipt->getPriceByCurrencyCode($sf_user->getAttribute('currency', 'EUR'))
                    											+ $receipt->getShippingPriceMinor($sf_user->getAttribute('currency', 'EUR'))
                    											, $sf_user->getAttribute('currency', 'EUR')) ?></td>
                    <td align="center"><?php echo link_to(
                                            image_tag(
                                                'userinfo.png'
                                                , array(
                                                    'alt' => __('User info')
                                                    , 'title' => __('User info')
                                                )
                                            )
                                        , 'cart/userinfo?cart=' . $receipt->getId()
                                        , array('popup' => array('popupWindow'
                                                                , 'width=310,height=400,left=320,top=0')))?></td>
                </tr>
            <?php endforeach; ?>
                <tr>
                    <th colspan="100%">&nbsp;</th>
                </tr>
            </table>

        <?php if ($pager->haveToPaginate()): ?>
            <div class="paging">
                <div class="paging_link">
                    <?php echo link_to(
                            '&laquo;'
                            , 'cart/list?page='.$pager->getFirstPage()
                        ) ?>
                </div>
                <div class="paging_link">
                    <?php echo link_to(
                            '&lsaquo;'
                            , 'cart/list?page='.$pager->getPreviousPage()
                        ) ?>
                </div>
                    <?php $links = $pager->getLinks(); foreach ($links as $page): ?>
                    <?php echo ($page == $pager->getPage()) ? '<div class="paging_current">' . $page . '</div>' : '<div class="paging_link">' . link_to($page, 'cart/list?page='.$page) . '</div>' ?>
                    <?php if ($page != $pager->getCurrentMaxLink()): ?>
                    <?php endif; ?>
                    <?php endforeach; ?>
                <div class="paging_link">
                    <?php echo link_to(
                                '&rsaquo;'
                                , 'cart/list?page='.$pager->getNextPage()
                            ) ?>
                </div>
                <div class="paging_link">
                    <?php echo link_to(
                                '&raquo;'
                                , 'cart/list?page='.$pager->getLastPage()
                            ) ?>
                </div>
            </div>
        <?php endif ?>

    <?php endif; /* END IF  (items to display) */ ?>

    </div>
</div>